using System.Data;
using Migrator.Framework;

namespace Bxo.Database {
    [Migration(200808192359)]
    public class M200808192359_CreateScenarioVersionsTable : Migration {
        public override void Up() {
            this.Database.AddTable(
                    "ScenarioVersions",
                    new Column("Id", DbType.Int32, ColumnProperty.Identity),
                    new Column("Scenario", DbType.Int32, ColumnProperty.NotNull),
                    // The null below is required by the NHibernate.
                    new Column("Position", DbType.Int32, ColumnProperty.Null),
                    new Column("Summary", DbType.String, 250, ColumnProperty.NotNull),
                    new Column("Instruction", DbType.String, ColumnProperty.NotNull),
                    new Column("CreationDateTime", DbType.DateTime, ColumnProperty.NotNull)
                    );
            this.Database.AddPrimaryKey("PK_ScenarioVersions", "ScenarioVersions", "Id");
            this.Database.AddForeignKey("FK_ScenarioVersions_Scenarios", "ScenarioVersions", "Scenario", "Scenarios", "Id");
        }

        public override void Down() {
            this.Database.RemoveForeignKey("Scenarios", "FK_ScenarioVersions_Scenarios");
            this.Database.RemoveTable("Scenarios");
        }
    }
}